package com.ihr360.job.core.item;

import com.ihr360.job.core.item.util.ExecutionContextUserSupport;

/**
 * Empty method implementation of {@link ItemStream}.
 *
 * @author Dave Syer
 * @author Dean de Bree
 *
 */
public abstract class ItemStreamSupport implements ItemStream {

    private final ExecutionContextUserSupport executionContextUserSupport = new ExecutionContextUserSupport();

    /**
     * No-op.
     * @see com.ihr360.job.core.item.ItemStream#close()
     */
    @Override
    public void close() {
    }

    /**
     * No-op.
     * @see com.ihr360.job.core.item.ItemStream#open(ExecutionContext)
     */
    @Override
    public void open(ExecutionContext executionContext) {
    }

    /**
     * Return empty {@link ExecutionContext}.
     * @see com.ihr360.job.core.item.ItemStream#update(ExecutionContext)
     */
    @Override
    public void update(ExecutionContext executionContext) {
    }

    /**
     * The name of the component which will be used as a stem for keys in the
     * {@link ExecutionContext}. Subclasses should provide a default value, e.g.
     * the short form of the class name.
     *
     * @param name the name for the component
     */
    public void setName(String name) {
        this.setExecutionContextName(name);
    }

    protected void setExecutionContextName(String name) {
        executionContextUserSupport.setName(name);
    }

    public String getExecutionContextKey(String key) {
        return executionContextUserSupport.getKey(key);
    }

}
